/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.agtranscontinental.dgs001.model;

import com.agtranscontinental.dgs001.dto.PersonalDto;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ericson
 */
@Entity
@Table(name = "personal")
@NamedQueries({
    @NamedQuery(name = "Personal.findAll", query = "SELECT p FROM Personal p"),
    @NamedQuery(name = "Personal.isUsuario", query = "SELECT p FROM Personal p where p.usrEps=:usrEps and p.clavEps=:clavEps")
})
public class Personal implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_psn")
    private Integer idPsn;
    @Size(max = 70)
    @Column(name = "nomb_psn")
    private String nombPsn;
    @Size(max = 70)
    @Column(name = "apld_psn")
    private String apldPsn;
    @Size(max = 11)
    @Column(name = "dni_psn")
    private String dniPsn;
    @Size(max = 15)
    @Column(name = "telfn_psn")
    private String telfnPsn;
    @Size(max = 15)
    @Column(name = "telfn2_psn")
    private String telfn2Psn;
    @Size(max = 15)
    @Column(name = "cell_psn")
    private String cellPsn;
    @Column(name = "tiplc_psn")
    private Integer tiplcPsn;
    @Size(max = 15)
    @Column(name = "cell2_psn")
    private String cell2Psn;
    @Column(name = "tiplc2_psn")
    private Integer tiplc2Psn;
    @Size(max = 10)
    @Column(name = "next_psn")
    private String nextPsn;
    @Size(max = 15)
    @Column(name = "rpm_psn")
    private String rpmPsn;
    @Size(max = 15)
    @Column(name = "rpc_psn")
    private String rpcPsn;
    @Size(max = 60)
    @Column(name = "coro_psn")
    private String coroPsn;
    @Column(name = "tip_psn")
    private Integer tipPsn;
    @Size(max = 20)
    @Column(name = "usr_eps")
    private String usrEps;
    @Size(max = 42)
    @Column(name = "clav_eps")
    private String clavEps;
    @Column(name = "estd_eps")
    private Integer estdEps;
    @Size(max = 15)
    @Column(name = "numrlcc_psn")
    private String numrlccPsn;
    @Size(max = 45)
    @Column(name = "catgralcc_psn")
    private String catgralccPsn;
    @Size(max = 15)
    @Column(name = "usracs_psn")
    private String usracsPsn;
    @JoinColumn(name = "id_pf", referencedColumnName = "id_pf")
    @ManyToOne
    private Perfil perfil;
    @JoinColumn(name = "id_eps", referencedColumnName = "id_eps")
    @ManyToOne(optional = false)
    private Empresa empresa;
    @JoinColumn(name = "id_cg", referencedColumnName = "id_cg")
    @ManyToOne(optional = false)
    private Cargo cargo;
    @JoinColumn(name = "id_ar", referencedColumnName = "id_ar")
    @ManyToOne(optional = false)
    private Area area;

    public Personal() {
    }

    public Personal(Integer idPsn) {
        this.idPsn = idPsn;
    }

    public Integer getIdPsn() {
        return idPsn;
    }

    public void setIdPsn(Integer idPsn) {
        this.idPsn = idPsn;
    }

    public String getNombPsn() {
        return nombPsn;
    }

    public void setNombPsn(String nombPsn) {
        this.nombPsn = nombPsn;
    }

    public String getApldPsn() {
        return apldPsn;
    }

    public void setApldPsn(String apldPsn) {
        this.apldPsn = apldPsn;
    }

    public String getDniPsn() {
        return dniPsn;
    }

    public void setDniPsn(String dniPsn) {
        this.dniPsn = dniPsn;
    }

    public String getTelfnPsn() {
        return telfnPsn;
    }

    public void setTelfnPsn(String telfnPsn) {
        this.telfnPsn = telfnPsn;
    }

    public String getTelfn2Psn() {
        return telfn2Psn;
    }

    public void setTelfn2Psn(String telfn2Psn) {
        this.telfn2Psn = telfn2Psn;
    }

    public String getCellPsn() {
        return cellPsn;
    }

    public void setCellPsn(String cellPsn) {
        this.cellPsn = cellPsn;
    }

    public Integer getTiplcPsn() {
        return tiplcPsn;
    }

    public void setTiplcPsn(Integer tiplcPsn) {
        this.tiplcPsn = tiplcPsn;
    }

    public String getCell2Psn() {
        return cell2Psn;
    }

    public void setCell2Psn(String cell2Psn) {
        this.cell2Psn = cell2Psn;
    }

    public Integer getTiplc2Psn() {
        return tiplc2Psn;
    }

    public void setTiplc2Psn(Integer tiplc2Psn) {
        this.tiplc2Psn = tiplc2Psn;
    }

    public String getNextPsn() {
        return nextPsn;
    }

    public void setNextPsn(String nextPsn) {
        this.nextPsn = nextPsn;
    }

    public String getRpmPsn() {
        return rpmPsn;
    }

    public void setRpmPsn(String rpmPsn) {
        this.rpmPsn = rpmPsn;
    }

    public String getRpcPsn() {
        return rpcPsn;
    }

    public void setRpcPsn(String rpcPsn) {
        this.rpcPsn = rpcPsn;
    }

    public String getCoroPsn() {
        return coroPsn;
    }

    public void setCoroPsn(String coroPsn) {
        this.coroPsn = coroPsn;
    }

    public Integer getTipPsn() {
        return tipPsn;
    }

    public void setTipPsn(Integer tipPsn) {
        this.tipPsn = tipPsn;
    }

    public String getUsrEps() {
        return usrEps;
    }

    public void setUsrEps(String usrEps) {
        this.usrEps = usrEps;
    }

    public String getClavEps() {
        return clavEps;
    }

    public void setClavEps(String clavEps) {
        this.clavEps = clavEps;
    }

    public Integer getEstdEps() {
        return estdEps;
    }

    public void setEstdEps(Integer estdEps) {
        this.estdEps = estdEps;
    }

    public String getNumrlccPsn() {
        return numrlccPsn;
    }

    public void setNumrlccPsn(String numrlccPsn) {
        this.numrlccPsn = numrlccPsn;
    }

    public String getCatgralccPsn() {
        return catgralccPsn;
    }

    public void setCatgralccPsn(String catgralccPsn) {
        this.catgralccPsn = catgralccPsn;
    }

    public String getUsracsPsn() {
        return usracsPsn;
    }

    public void setUsracsPsn(String usracsPsn) {
        this.usracsPsn = usracsPsn;
    }

    public Perfil getPerfil() {
        return perfil;
    }

    public void setPerfil(Perfil perfil) {
        this.perfil = perfil;
    }

    public Empresa getEmpresa() {
        return empresa;
    }

    public void setEmpresa(Empresa empresa) {
        this.empresa = empresa;
    }

    public Cargo getCargo() {
        return cargo;
    }

    public void setCargo(Cargo cargo) {
        this.cargo = cargo;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPsn != null ? idPsn.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Personal)) {
            return false;
        }
        Personal other = (Personal) object;
        if ((this.idPsn == null && other.idPsn != null) || (this.idPsn != null && !this.idPsn.equals(other.idPsn))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agtranconstinental.dgs001.model.Personal[ idPsn=" + idPsn + " ]";
    }
    
    public PersonalDto toPersonalDto(){
        PersonalDto pdto = new PersonalDto();
        pdto.setId(getIdPsn());
        pdto.setNickname(getUsrEps());
        pdto.setPassword(getClavEps());
        pdto.setNombre(getNombPsn());
        pdto.setApellidos(getApldPsn());
        return pdto;
    }
}
